package com.alvinlkk.basic.chapter21;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//每个任务都会创建一个线程
public class CachedThreadPool {
    
    public static void main(String[] args) {
        ExecutorService exec = Executors.newCachedThreadPool();
        for(int i=0; i < 5; i ++) {
            exec.execute(new LiftOff());
        }
        exec.shutdown();  //可以防止新任务被提交到这个Executor上
    }
}
